const debounce = <T = any>( fn:Function, delay:number = 500 ) => {
	let timer:NodeJS.Timer | null = null
	return function(...args: Array<T>) {
		if (timer !== null) {
			clearTimeout(timer)
		}
		timer = setTimeout(() => {
			fn.apply(this, args)
		},delay)
	}
}

export default debounce

